/*
Copyright (C) 2010 
Author		  Oliver Schenk
Contact		  Oliver.Schenk76@gmail.com

This program is free software; you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; 
if not, see <http://www.gnu.org/licenses/>.
*/

<%@ page language="java" import="java.util.*,java.text.*"%>
<%@ page import="java.net.MalformedURLException" %>
<%@ page import="java.net.URL" %>
<%@ page import="com.google.gdata.client.calendar.*" %>
<%@ page import="com.google.gdata.data.calendar.*" %>
<%@ page import="com.google.gdata.client.*" %>
<%@ page import="com.google.gdata.data.*" %>
<%@ page import="com.google.gdata.model.*" %>
<%@ page import="com.google.gdata.util.*" %>
<%@ page import="com.google.gdata.data.calendar.*" %>
<%@ page import="com.google.gdata.data.extensions.*" %>
<%@ page import="com.google.gdata.data.*" %>
<%@ page import="com.google.gdata.client.http.*" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="SelfBookingSystem.AdminValues" %>
<%@ page import="SelfBookingSystem.PMF" %>
<%@ page import="org.apache.commons.configuration.*" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="SelfBookingSystem.MyFramework.ReadConfigXML" %>
<%@ page import="SelfBookingSystem.MyFramework.HTMLFormGenerator" %>

<%!
public int nullIntconv(String inv)
{   
	int conv=0;
		
	try{
		conv=Integer.parseInt(inv);
	}
	catch(Exception e)
	{}
	return conv;
}

%>
<!--If this page is not called embedded in index.php forward to index.php-->
<script type="text/javascript">
if(window.location.pathname.indexOf("index") == -1){
	window.location.href = "index.jsp";
}
</script>
<%
//Variablen Deklaration
String GoogleCalendardURL;
String GoogleEmail;
String Password;
String tmp;
String value;
String checked;
String BadCredentials = new String();;
String Credential = new String();
String AppID = new String();
   
//Get Userdata
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();	
   
if(request.getParameter("AppID") != null){
	AppID = request.getParameter("AppID");
}else{
	AppID = "xxx";
}
 
 ReadConfigXML myValueList = new ReadConfigXML("config/","UserInformation.xml");
 
 
    //XMLConfiguration fields = new XMLConfiguration("config/AdminFields.xml");
    // do something with config
   	//System.out.println("JSP: Field[0]: " + fields.getString("tables.table.fields.field(1).name"));

	myValueList.setValueList("tables.table.fields.field");
	HTMLFormGenerator myHTMLForm = new HTMLFormGenerator();
	String TableContent = "\n<table>";
	TableContent += myHTMLForm.FormOpen("/AddUserInformation", null , "post");
	for(Iterator it = myValueList.getValueList().iterator(); it.hasNext();)
	{
		HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
		System.out.println("TEST: " + sub.getString("HTMLField.type"));
		
		TableContent += "\n<tr>";
		TableContent += "\n<td>" + sub.getString("HTMLField.name") +"</td>";
		TableContent += "\n<td>" + myHTMLForm.TextElement( sub.getString("HTMLField.name"), "50", null , null) +"</td>";
		TableContent += "\n</tr>";
	}
	
	TableContent += "\n<tr>";
	TableContent += "\n<td colspan=\"2\">" + myHTMLForm.FormSubmit("Save values") + "</td>";
	TableContent += "\n</tr>";
	
	TableContent += myHTMLForm.HiddenElement( "AppID", AppID);
	TableContent += myHTMLForm.FormClose();
	
	
	
	
	
	
	TableContent += "\n</table>";

	
%>	

<%=TableContent%>


